package com.iflytek.universitymanagement.controller;

import com.iflytek.universitymanagement.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


@RestController
@RequestMapping("/api/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    @GetMapping("/dashboard")
    public Map<String, Object> getDashboardStatistics() {
        Map<String, Object> stats = new HashMap<>();
        stats.put("studentCount", statisticsService.getStudentCount());
        stats.put("courseCount", statisticsService.getCourseCount());
        stats.put("competitionParticipationCount", statisticsService.getCompetitionParticipationCount());
        stats.put("averageCompletionRate", statisticsService.getAverageCompletionRate());
        return stats;
    }
}

